﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;
namespace ZF.WS.news
{
    public partial class banner : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {

                string[] types = DictionaryConfig.INewType.Select(p => p.Key).ToArray();
                Dictionary<object, List<Model.I_News>> dicType = null;
                var cacheKey = "_Index_News";
                var obj = HttpCache.GetCache(cacheKey);
                if (obj != null)
                {
                    dicType = obj as Dictionary<object, List<Model.I_News>>;
                }
                else
                {
                    dicType = new Dictionary<object, List<Model.I_News>>();
                    foreach (var type in types)
                    {
                        var list = dc.I_News.Where(p => p.Type == type && p.IsV)
                            .OrderBy(p => p.Focus)
                            .OrderByDescending(p => p.NewsId).Take(12)
                            .ToList();

                        dicType[type] = list;
                    }

                    SiteInfo.Instance.SetPageCache(cacheKey, dicType);
                }
                


                var gzList = dicType["特别关注"].Take(5);//特别关注
                this.lvTBGZ.DataSource = gzList;
                this.lvTBGZ.DataBind();
         

            }
        }
    }
}
